package com.ysx.server.mapper;

import com.github.pagehelper.Page;
import com.ysx.server.pojo.dto.UserDTO;
import com.ysx.server.pojo.dto.UserPageQueryDTO;
import com.ysx.server.pojo.entity.User;
import com.ysx.server.pojo.vo.UserInfoVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    /**
     * 通过账户查找用户
     * @param account
     * @return
     */
    @Select("select * from user where userAccount=#{account}")
    User getByAccount(String account);

    /**
     * 保存用户
     * @param userAccount
     * @param userPassword
     */
    @Insert("insert into second_hand_trading.user (userAccount, userPassword) values(#{param1},#{param2})")
    void save(String userAccount,String userPassword);

    /**
     * 获取用户信息
     * @return
     */
    Page<UserInfoVO> getUserManage(UserPageQueryDTO userPageQueryDTO);

    /**
     * 删除用户
     * @param id 用户id
     * @return
     */
    boolean delete(Long id);

    /**
     * 保存用户
     * @param user
     * @return
     */
    boolean saveUser(User user);

    /**
     * 修改用户信息
     * @param userDTO
     * @return
     */
    boolean update(UserDTO userDTO);

    /**
     * 通过id查找用户
     * @param userId
     * @return
     */
    @Select("select * from second_hand_trading.user where id=#{userId}")
    User getById(Long userId);
}
